<?php
include "../../Koneksi/koneksi.php";
$cekJumlah = mysql_query("select count(kodeAspekKetrampilan) 'jumlah' from aspekKetrampilan");
           
$cekKode=mysql_fetch_array($cekJumlah);
$kodeAspekPengetahuan = $cekKode['jumlah']+1;

$materiUH1 = $_POST['materiUH1'];
$materiUH2 = $_POST['materiUH2'];
$materiUH3 = $_POST['materiUH3'];
$materiUH4 = $_POST['materiUH4'];
$materiUH5 = $_POST['materiUH5'];
$materiUH6 = $_POST['materiUH6'];
$no = $_POST['no'];
$nama = $_POST['nama'];
$uk1 = $_POST['uk1'];
$uk2 = $_POST['uk2'];
$uk3 = $_POST['uk3'];
$uk4 = $_POST['uk4'];
$uk5 = $_POST['uk5'];
$uk6 = $_POST['uk6'];
$rerataUK=($uk1+$uk2+$uk3+$uk4+$uk5+$uk6)/6;
$project1= $_POST['project1'];
$project2= $_POST['project2'];
$project3= $_POST['project3'];
$rerataProject=($project1+$project2+$project3)/3;
$fortofolio1= $_POST['fortofolio1'];
$fortofolio2= $_POST['fortofolio2'];
$rerataFortofolio=($fortofolio1+$fortofolio2)/2;
$nilai100=($rerataUK*2+$rerataProject+$rerataFortofolio)/4;
$nilai4=($nilai100/100)*4;
$konversi="";

if($nilai4>3.84){
    $konversi="A";
}else if($nilai4>3.5 && $nilai4<=3.84){
    $konversi="A-";
}else if($nilai4>3.17 && $nilai4<=3.5){
    $konversi="B+";
}else if($nilai4>2.84 && $nilai4<=3.17){
    $konversi="B";
}else if($nilai4>2.5 && $nilai4<=2.84){
    $konversi="B-";
}else if($nilai4>2.17 && $nilai4<=2.5){
    $konversi="C+";
}else if($nilai4>1.84 && $nilai4<=2.17){
    $konversi="C";
}else if($nilai4>1.5 && $nilai4<=1.84){
    $konversi="C-";
}else if($nilai4>1.17 && $nilai4<=1.5){
    $konversi="D+";
}else{
    $konversi="D";
}
$keterangan="";
$cekkkm = mysql_fetch_array(mysql_query("SELECT kkmKetrampilan FROM gurumapel where kodeGuruMapel='INA_1122'"));
if($nilai4>=$cekkkm['kkmKetrampilan']){
    $keterangan="Tuntas";
}else{
    $keterangan="Tidak Tuntas";
}

$ceknis = mysql_fetch_array(mysql_query("SELECT nis FROM pesertadidik where nama='$nama'"));


//$cek = mysql_fetch_array(mysql_query("SELECT * FROM aspekPengetahuan where pesertadidik='$nama' "
//        . "WHERE g.pendidik=p.nip and g.matapelajaran=m.kodemapel and g.kkmPengetahuan is not null "
//        . "and g.pendidik='1122'"));
//if (($cek['kodeGuruMapel']!=null)) {

    mysql_query("Insert into aspekketrampilan (kodeaspekKetrampilan, gurumapel, pesertadidik, "
            . "uk1, uk2, uk3, uk4, uk5, uk6, rerataUK, projek1, projek2, projek3, "
            . "rerataProjek, portofolio1, portofolio2, rerataportofolio, nilai100, nilai4, konversi, keterangan, "
            . "materiUH1, materiUH2, materiUH3, materiUH4, materiUH5, materiUH6) value "
            . "($kodeAspekPengetahuan, 'INA_1122', '0123', '$uk1', '$uk2', '$uk3', '$uk4', '$uk5', '$uk6', "
            . "'$rerataUK', '$project1', '$project2', '$project3', '$rerataProject', '$fortofolio1', '$fortofolio2', "
            . "'$rerataFortofolio', '$nilai100', '$nilai4', '$konversi', '$keterangan', "
            . "'$materiUH1', '$materiUH2', '$materiUH3', '$materiUH4', '$materiUH5', '$materiUH6')");
    

    ?>
    <script>alert("Data berhasil disimpan");
                    document.location.href = "../Form/FormAspekKetrampilan.php"</script>
    <?php

?>